﻿using IBLL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace work37API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        public UserController(IUserBLL bll)
        {
            Bll = bll;
        }

        public IUserBLL Bll { get; }
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddUser(UserModel model)
        {
            return await Bll.AddUser(model);
        }
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <returns></returns>
        [HttpGet]
        public dynamic GetAll(int PageSize, int PageIndex)
        {
            return Bll.GetAll(PageSize, PageIndex); 
        }
        /// <summary>
        /// 根据Id查所有
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public UserModel GetAllUser(int id)
        {
            return Bll.GetAllUser(id);
        }
        /// <summary>
        /// 批量逻辑删除
        /// </summary>
        /// <param name="Delstring"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> UpdateUser(string Delstring)
        {
            return await Bll.UpdateUser(Delstring);
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="UserZH"></param>
        /// <param name="UserPwd"></param>
        /// <returns></returns>
        [HttpGet]
        public UserModel UserLogin(string UserZH, string UserPwd)
        {
            return Bll.UserLogin(UserZH, UserPwd);
        }
    }
}
